#ifndef HEADER_H
#define HEADER_H

#include <iostream>
#include <string>
#include <list>
#include <vector>
#include "utils/file.h"
#include <curl/curl.h>

using namespace base::utils;
using namespace std;

enum class DataType
{
    Bool = 0,
    Uint8,
    Uint8Array,
    Uint16,
    Uint16Array,
    Uint32,
    Uint32Array,
    Uint64,
    Uint64Array,
    Int8,
    Int8Array,
    Int16,
    Int16Array,
    Int32,
    Int32Array,
    Int64,
    Int64Array,
    Float32,
    Float32Array,
    Float64,
    Float64Array,
    String,
    Duration
};

struct Data
{
    Data(DataType type, std::string name)
        : type(type), name(std::move(name))
    {}
    DataType type;
    std::string name;
};

const std::string MAS_URI = "192.168.101.101:11311";

std::string readFile(const std::string &file_name)
{
    base::utils::File file(file_name);
    if (!file.open(base::utils::file::ReadOnly))
    {
        std::cout << "open file " << file_name << " fail" << std::endl;
        return "";
    }
    std::string xml_data = file.readAll();
    file.close();
    return xml_data;
}

size_t GetResponse(char *ptr, size_t size, size_t nmemb, void *userdata)
{
    size_t realSize = size * nmemb;
    ((std::string *) userdata)->append((char *) ptr, realSize);
    return realSize;
}

#endif //HEADER_H
